diff --git a/chroot/etc/nginx/template/nginx.tmpl b/chroot/etc/nginx/template/nginx.tmpl
index 94dc12412..93b7d2efc 100644
--- a/chroot/etc/nginx/template/nginx.tmpl
+++ b/chroot/etc/nginx/template/nginx.tmpl
@@ -12,6 +12,9 @@
 # setup custom paths that do not require root access
 pid {{ .PID }};
 
+# enables the use of “just-in-time compilation” for the regular expressions known by the time of configuration parsing
+pcre_jit on;
+
 {{ if $cfg.UseGeoIP2 }}
 load_module /etc/nginx/modules/ngx_http_geoip2_module.so;
 {{ end }}
@@ -98,11 +101,11 @@ http {
         end
 
         {{ if $all.EnableMetrics }}
-        ok, res = pcall(require, "monitor")
+        ok, res = pcall(require, "pbmetrics")
         if not ok then
           error("require failed: " .. tostring(res))
         else
-          monitor = res
+          pbmetrics = res
         end
         {{ end }}
 
@@ -127,11 +130,9 @@ http {
     init_worker_by_lua_block {
         lua_ingress.init_worker()
         balancer.init_worker()
-        {{ if $all.EnableMetrics }}
-        monitor.init_worker({{ $all.MonitorMaxBatchSize }})
-        {{ end }}
 
         plugins.run()
+        pbmetrics.init_worker()
     }
 
     {{/* Enable the real_ip module only if we use either X-Forwarded headers or Proxy Protocol. */}}
@@ -166,6 +167,16 @@ http {
 
     {{ end }}
 
+    {{ if $cfg.UseGeoIP }}
+    {{/* databases used to determine the country depending on the client IP address */}}
+    {{/* http://nginx.org/en/docs/http/ngx_http_geoip_module.html */}}
+    {{/* this is require to calculate traffic for individual country using GeoIP in the status page */}}
+    geoip_country       /etc/nginx/geoip/GeoIP.dat;
+    geoip_city          /etc/nginx/geoip/GeoLiteCity.dat;
+    geoip_org           /etc/nginx/geoip/GeoIPASNum.dat;
+    geoip_proxy_recursive on;
+    {{ end }}
+
     {{ if $cfg.UseGeoIP2 }}
     # https://github.com/leev/ngx_http_geoip2_module#example-usage
 
@@ -387,6 +387,12 @@ http {
         {{ $reqUri }} 0;{{ end }}
         default 1;
     }
+    map $server_name $total_upstream_response_time {
+        default 0;
+    }
+    map $server_name $upstream_retries {
+        default 0;
+    }
 
     {{ if or $cfg.DisableAccessLog $cfg.DisableHTTPAccessLog }}
     access_log off;
@@ -928,9 +939,7 @@ stream {
 
             proxy_pass            http://upstream_balancer;
             log_by_lua_block {
-                {{ if $enableMetrics }}
-                monitor.call()
-                {{ end }}
+                pbmetrics.call()
             }
         }
         {{ end }}
@@ -1223,6 +1232,8 @@ stream {
             set $location_path  {{ $ing.Path | escapeLiteralDollar | quote }};
             set $global_rate_limit_exceeding n;
 
+            set $content_kind "";
+
             {{ buildOpentelemetryForLocation $all.Cfg.EnableOpentelemetry $all.Cfg.OpentelemetryTrustIncomingSpan $location }}
 
             {{ if $location.Mirror.Source }}
@@ -1253,11 +1266,9 @@ stream {
 
             log_by_lua_block {
                 balancer.log()
-                {{ if $all.EnableMetrics }}
-                monitor.call()
-                {{ end }}
 
                 plugins.run()
+                pbmetrics.call()
             }
 
             {{ if not $location.Logs.Access }}
@@ -1531,14 +1542,15 @@ stream {
 
         {{ if eq $server.Hostname "_" }}
         # health checks in cloud providers require the use of port {{ $all.ListenPorts.HTTP }}
-        location {{ $all.HealthzURI }} {
+        location = {{ $all.HealthzURI }} {
 
             {{ if $all.Cfg.EnableOpentelemetry }}
             opentelemetry off;
             {{ end }}
 
             access_log off;
-            return 200;
+            proxy_set_header D8s-External-Check "True";
+            proxy_pass http://127.0.0.1:10254;
         }
 
         # this is required to avoid error if nginx is being monitored
